<template>
	<div class="index__partBox__src-partition-zone-">
		<div class="index__firstContainer__src-partition-zone-">
			<div class="index__pagesContainer__src-partition-zone-">
				<div class="index__scrollContainer__src-partition-zone-">
					<router-link class="index__tab__src-partition-zone-tab- " to="/"><p>首页</p></router-link>
					<router-link :class="{active:item.tid==getcurtid}" class="index__tab__src-partition-zone-tab- " v-for="(item,index) in newlist" :key="index"  :to="{name:'channel',params:{tid:item.tid}}" v-if="item.typename.split('').length<=2" exact>
						<p>{{item.typename}}</p>
					</router-link>
					<router-link v-else  class="index__tab__src-partition-zone-tab- index__big__src-partition-zone-tab- ":to="{name:'channel',params:{tid:item.tid}}" exact>
						<p>{{item.typename}}</p>
					</router-link>
					<a class="index__tab__src-partition-zone-tab- " href="//live.bilibili.com/h5/">
						<p>直播</p>
					</a>
					<a class="index__tab__src-partition-zone-tab- " href="//h.bilibili.com/ywh/h5/home">
						<p>相簿</p>
					</a>
					<div></div>
				</div>
			</div>
			<div class="index__switchContainer__src-partition-zone-">
				<svg class="index__icon__src-partition-zone-" aria-hidden="true">
					<use xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="#icon-xialaxiao"></use>
				</svg>
			</div>
		</div>
		<fnav3 :tid="parent_tid" v-on:Pchangetid="changetid"></fnav3>
	</div>
</template>

<script>
	import config from "@/config";
	import axios from "axios";
	import fnav3 from 'components/nav/f_nav3';
	export default {
		name: 'bnav',
		data() {
			return {
				newlist: [],
				parent_tid:this.$route.params.tid,
			}
		},
		mounted() {
			this.newlist=window.__INITIAL_STATE__.reduxAsyncConnect.partitionList[0]
		},
		methods: {
			changetid(tid){
//				tid来自于子组件的
				this.parent_tid=tid;
			},
		},
		components:{
			fnav3,
		},
		computed:{
			getCount(){
				return this.$store.getters.getCount
			},
			getcurtid(){
				//拿到对应的键名
				return this.$store.getters.getcurtid
			}
		},
		watch:{
			$route(newValue,oldValue){
				console.log(newValue)
				if(newValue.path.indexOf("channel")){
					this.$store.commit('setcurtid',{
						curtid:newValue.params.tid
					})
					this.parent_tid=newValue.params.tid
				}
			}
		},
		created(){
			this.$store.commit('setcurtid',{
				curtid:this.$route.params.tid
			})
		},
	}
</script>

<style lang="scss">
@import "../../common/scss/nav";
	.active p{
		width: 1.36533rem;
	    font-size: .59733rem;
	    line-height: 1.28rem;
	    text-align: center;
	    color: #fb7299;
	    border-bottom: .08533rem solid #fb7299;
	}
	.router-link-exact-active p{
	    font-size: .59733rem;
	    line-height: 1.28rem;
	    text-align: center;
	    color: #fb7299;
	}
	
</style>